package backend.task;

import java.io.File;
import java.io.Serializable;


public class FileTask implements Serializable,Comparable{
	
	/**
     * 
     */
    private static final long serialVersionUID = -6326014460908603050L;
	private String uid ;
    private File file;
    private int status;
    private long lastReadLine;//line based
    private long totalLine;

	public FileTask(){
    	
    }
    /**
     * a default manner
     */
    public FileTask(File file){
    	this.file = file;
    	status = 0;
    	lastReadLine = 0;
    }
	
    
    public String getUid() {
		return uid;
	}
	public void setUid(String uid) {
		this.uid = uid;
	}
	public long getLastModified(){
    	return file!=null ? file.lastModified():0L;
    }
    
    public File getFile() {
    	return file;
    }

	
    public void setFile(File file) {
    	this.file = file;
    }

	public int getStatus() {
    	return status;
    }
	
    public void setStatus(int status) {
    	this.status = status;
    }
	
    public long getLastReadLine() {
    	return lastReadLine;
    }
	
    public void setLastReadLine(long lastReadLine) {
    	this.lastReadLine = lastReadLine;
    }
	
    public long getTotalLine() {
    	return totalLine;
    }
	
    public void setTotalLine(long totalLine) {
    	this.totalLine = totalLine;
    }

	public int compareTo(Object o) {
	    if(o instanceof FileTask){
	    	FileTask t = (FileTask) o;
			return this.getLastModified() - t.getLastModified() >= 0 ? 1 : -1;
	    }
	    return 0;
    }
	
	public String toString(){
		return file.getName()+" "+ file.lastModified();
	}

	
	/**
	 * uid 
	 * 
	 * @return
	 */
	public String fetchTag(){
		String fileName = file.getName();	
		return fileName.substring(0,fileName.indexOf("-"));
	}
	



    
    
	
}
